// =================================================================================================
//
//	CopyEngine Framework
//	Copyright 2012 Eran. All Rights Reserved.
//
//	This program is free software. You can redistribute and/or modify it
//	in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================

package gui.itemSetting.propertySetting.relateScreenChoice
{
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.MouseEvent;

    public class RelateScreenChoiceDotComponent
    {
        private var mDotMc:MovieClip;
        private var mOnClickDotCallback:Function;
        private var mDotID:String;

        public function RelateScreenChoiceDotComponent()
        {
        }

        //==================================
        //== Initialize & Dispose
        //==================================

        public function initialize(_dotMc:MovieClip, _dotID:String, _onClickDotCallback:Function):void
        {
            mDotMc = _dotMc;
            mDotID = _dotID;
            mDotMc.gotoAndStop(1);
            mOnClickDotCallback = _onClickDotCallback;
            addListener();
        }

        //==================================
        //== Public Function
        //==================================

        public function set selected(_isSelected:Boolean):void
        {
            if (_isSelected)
            {
                mDotMc.gotoAndStop(2);
            }
            else
            {
                mDotMc.gotoAndStop(1);
            }
        }

        public function get dotID():String {return mDotID;}

        //==================================
        //== Private Function
        //==================================

        private function addListener():void
        {
            mDotMc.addEventListener(MouseEvent.MOUSE_DOWN, onClickDotMc)
        }

        private function onClickDotMc(e:Event):void
        {
            mOnClickDotCallback(this);
        }

    }
}
